<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.8.2.js"></script>
</head>
<body>
    <center>
        <form action="cusReg.do" method="post">
            <table border="1" rules="all">
                <tr>
                    <td>账户名称</td>
                    <td><input type="text" name="cname"/></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" name="pwd"/></td>
                </tr>
                <tr>
                    <td>确认密码</td>
                    <td><input type="password" id="pwd2"/></td>
                </tr>
                <tr>
                    <td>手机号</td>
                    <td><input type="tel" name="tel"/>
                        <a href="#" onclick="getcode()">获取验证码</a>
                    </td>
                </tr>
                <tr  hidden id="yzm">
                    <td>验证码</td>
                    <td><input type="text" name="ycode"/></td>
                </tr>
                <tr>
                    <td>邮箱</td>
                    <td><input type="email" name="cemail"/></td>
                </tr>
                <tr>
                    <td colspan="12"><input type="button" value="注册" onclick="checkcus()"/></td>
                </tr>
            </table>
        </form>
    </center>
</body>
<script>
    function checkcus() {
        document.forms[0].submit();
    }
</script>
<script>
    function getcode() {
        var tel = $("[name='tel']").val();
        if(tel!=null){
            $.post(
                "getCode.do",
                    {tel:tel},
                    function (data) {
                        if(data=="no"){
                            alert("获取验证码失败");
                        }else{
                            $("#yzm").show();
                        }
                    }
            );
        }else{
            alert("手机号码非法");
        }
    }
</script>
</html>